Sales Hub Testing Guide
๐ Quick Start
1. Access the Dashboard
**Development:**
http://localhost:3000/dashboards/sales**Production:**
https://atom-saas.fly.dev/dashboards/sales2. Test Data Overview
The seed script created:
- **Tenant ID**:
demo_tenant - **3 Leads**: ceo@growthcorp.com, marketing@startup.io, competitor@rival.com
- **4 Deals**:
- Enterprise License - GrowthCorp ($120,000, Negotiation)
- Global Rollout - TechSystems ($250,000, Proposal) - **Stalled for 20 days**
- Team Expansion - StartupIO ($45,000, Qualification)
- Security Upgrade - FinanceCorp ($85,000, Discovery) - **Stalled for 30 days**
---
๐งช API Testing
Test 1: Dashboard Stats
**Endpoint:** GET /api/sales/dashboard/stats
**Expected Response:**
{
"total_pipeline": 500000,
"active_deals_count": 4,
"key_contacts": 0,
"win_rate": 0,
"weighted_forecast": 212500,
"deals_by_stage": {
"discovery": 1,
"qualification": 1,
"proposal": 1,
"negotiation": 1
}
}**Test Command:**
curl https://atom-saas.fly.dev/api/sales/dashboard/stats | jq '.'---
Test 2: AI Insights
**Endpoint:** GET /api/sales/insights
**Expected Response:**
{
"status": "success",
"count": 2,
"insights": [
{
"anomaly_id": "stalled_deal_[id]",
"severity": "warning",
"title": "Deal 'Global Rollout - TechSystems' stalled for 20 days",
"description": "Deal worth $250,000 hasn't moved in 20 days",
"recommendation": "Send follow-up email or schedule call to re-engage",
"action_type": "email"
},
{
"anomaly_id": "stalled_deal_[id]",
"severity": "critical",
"title": "Deal 'Security Upgrade - FinanceCorp' stalled for 30 days",
"description": "Deal worth $85,000 hasn't moved in 30 days",
"recommendation": "Send follow-up email or schedule call to re-engage",
"action_type": "email"
}
]
}**Test Command:**
curl https://atom-saas.fly.dev/api/sales/insights | jq '.insights[] | {severity, title, description}'---
Test 3: Sales Activities
**Endpoint:** GET /api/sales/activities?limit=10
**Expected Response:**
{
"status": "success",
"activities": [
{
"id": "[activity_id]",
"type": "created",
"description": "Deal 'Enterprise License - GrowthCorp' created worth $120,000",
"deal_id": "[deal_id]",
"deal_name": "Enterprise License - GrowthCorp",
"deal_value": 120000,
"timestamp": "2025-03-06T..."
}
],
"total_count": 4
}**Test Command:**
curl https://atom-saas.fly.dev/api/sales/activities?limit=10 | jq '.activities[] | {type, description, deal_name}'---
Test 4: Revenue Forecast
**Endpoint:** GET /api/sales/forecast?months=3
**Expected Response:**
{
"status": "success",
"forecast": [
{
"month": "March 2025",
"weighted_forecast": 0,
"best_case": 0,
"worst_case": 0,
"deal_count": 0,
"confidence": 0
}
],
"summary": {
"total_weighted_forecast": 0,
"total_best_case": 0,
"total_worst_case": 0,
"total_deals": 0,
"avg_confidence": 0
}
}**Test Command:**
curl https://atom-saas.fly.dev/api/sales/forecast?months=3 | jq '.'---
Test 5: Pipeline
**Endpoint:** GET /api/sales/pipeline
**Expected Response:**
[
{
"deal": "Enterprise License - GrowthCorp",
"value": 120000,
"status": "negotiation",
"platform": "salesforce",
"company": "GrowthCorp"
},
{
"deal": "Global Rollout - TechSystems",
"value": 250000,
"status": "proposal",
"platform": "hubspot",
"company": "TechSystems"
}
]**Test Command:**
curl https://atom-saas.fly.dev/api/sales/pipeline | jq '.[] | {deal, value, status, company}'---
๐จ Frontend Testing
1. Visual Inspection
Navigate to /dashboards/sales and verify:
**Dashboard Metrics:**
- โ Total Pipeline: $500.0k
- โ Active Deals: 4
- โ Win Rate: 0% (no closed deals yet)
- โ All cards show data, not zeros
**Deals Table:**
- โ Shows 4 deals
- โ Values are correct
- โ Stages are displayed
- โ Platform badges shown
**AI Insights Panel:**
- โ Shows 2 stalled deal warnings
- โ One warning (20 days)
- โ One critical (30 days)
- โ Action buttons visible
**Activity Feed:**
- โ Shows 4 activities
- โ Deal creation logs visible
- โ Timestamps correct
**Revenue Forecast:**
- โ Shows 3 months
- โ Confidence bars visible
- โ Deal counts displayed
---
๐ Database Verification
Connect to Database
# Using psql
psql $DATABASE_URL
# Or using Python
cd backend-saas
python -c "
from core.database import SessionLocal
from core.models import Deal, Lead, SalesActivity
db = SessionLocal()
print(f'Deals: {db.query(Deal).count()}')
print(f'Leads: {db.query(Lead).count()}')
print(f'Activities: {db.query(SalesActivity).count()}')
"Verify Data
**Check Deals:**
SELECT name, value, stage, probability, updated_at
FROM deals
WHERE tenant_id = 'demo_tenant'
ORDER BY updated_at DESC;**Check Insights:**
SELECT name, value, stage,
EXTRACT(DAY FROM (NOW() - updated_at)) as days_stalled
FROM deals
WHERE tenant_id = 'demo_tenant'
AND updated_at < NOW() - INTERVAL '14 days';---
๐ Troubleshooting
Issue: "No data showing"
**Solution:**
- Check browser console for API errors
- Verify tenant_id is correct
- Check network tab in browser DevTools
- Run:
curl https://atom-saas.fly.dev/api/sales/dashboard/stats
Issue: "Insights not loading"
**Solution:**
- Verify deals have updated_at timestamps
- Check backend logs:
fly logs -a atom-saas --tail 100 - Ensure deals exist in database
- Test insights endpoint directly
Issue: "Activities not showing"
**Solution:**
- Check sales_activities table
- Verify tenant_id matches
- Check SalesActivityService logs
- Test activities endpoint directly
Issue: "Forecast shows 0"
**Solution:**
- Ensure deals have expected_close_date set
- Check probability values are set
- Verify deals are in active stages
- Test forecast endpoint directly
---
โ Testing Checklist
- [ ] Dashboard loads without errors
- [ ] All metric cards show correct values
- [ ] Deals table displays all 4 test deals
- [ ] AI Insights panel shows stalled deal warnings
- [ ] Activity feed shows creation logs
- [ ] Revenue forecast displays 3 months
- [ ] Refresh button works
- [ ] No console errors in browser
- [ ] API endpoints return correct data
- [ ] Multi-tenant isolation works (only see your data)
---
๐ Debug Mode
Enable Debug Logging
**Backend:**
# In backend-saas/sales/routes.py
import logging
logging.basicConfig(level=logging.DEBUG)**Frontend:**
// In browser console
localStorage.setItem('debug', 'true');Check WebSocket Connection
// In browser console
const ws = new WebSocket('wss://atom-saas.fly.dev/ws');
ws.onopen = () => console.log('โ
WebSocket connected');
ws.onerror = (error) => console.error('โ WebSocket error:', error);---
๐ Performance Testing
Load Test
# Install hey
go install github.com/rakyll/hey@latest
# Test dashboard stats endpoint
hey -n 100 -c 10 https://atom-saas.fly.dev/api/sales/dashboard/stats
# Test insights endpoint
hey -n 100 -c 10 https://atom-saas.fly.dev/api/sales/insightsMonitor Response Times
# Test all endpoints
for endpoint in "dashboard/stats" "insights" "activities?limit=10" "forecast?months=3" "pipeline"; do
echo "Testing /api/sales/$endpoint"
time curl -s "https://atom-saas.fly.dev/api/sales/$endpoint" > /dev/null
echo ""
done---
๐ฏ Expected Results
After running all tests, you should see:
- **Dashboard Metrics**: Total pipeline of $500k, 4 active deals
- **AI Insights**: 2 stalled deal warnings (1 warning, 1 critical)
- **Activities**: 4 deal creation activities
- **Forecast**: 3-month forecast with 0 confidence (no close dates set)
- **Pipeline**: 4 deals with correct stages and values
---
๐ Support
If you encounter issues:
- Check backend logs:
fly logs -a atom-saas --tail 100 - Check database: Connect via psql or Neon console
- Check audit logs:
SELECT * FROM saas_audit_logs ORDER BY timestamp DESC LIMIT 20; - Review browser console and network tab
---
**Last Updated:** March 6, 2025
**Status:** โ Ready for Testing